// pages/my/my.js
var util = require('../../utils/util.js');
const app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    userInfo:'',
    urlList: [ { url: '../forgetPwd/forgetPwd', title:'修改密码'}
      , { url: '/pages/roomPattern/roomPattern', title: '房态图' }, { url: '/pages/my/service/service_list', title: '购买服务' }
    ],//{ url: '/pages/my/electronSign/electronSign', title: 'e签宝' },
    urlList2: [{ url: '/pages/my/service/service_list', title: '购买服务' }, { url: '/pages/aduting/resversion/resersion_list', title: '预约列表'}],
    urldetail:[],
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    wx.getStorage({
      key: 'userInfo',
      success: function (res) {
        that.setData({
          userInfo: res.data
        })
        if (res.data.user_type_id == 10006) {
          app.editTabBar2();
          that.setData({
            urldetail: that.data.urlList2
          })
        }else{
          app.editTabBar();
          that.setData({
            urldetail: that.data.urlList
          })
        }
      },
      fail:function(){
        wx.redirectTo({
          url: '../index/index',
        })
      }
    })
  },
  loginOut:function(){
    var that=this;
    wx.showModal({
      title: '提示',
      content: '是否退出登录?',
      mode: true,
      showCancel: true,
      confirmColor: '#007aff',
      success: function (res) {
        if (res.confirm) {
           var userInfo=that.data.userInfo
           util.getReq('/app/logout', { uid: userInfo.user_id, source: userInfo.source,mobile:userInfo.phone_num }, function (data) {
            if (data.code == 0) {
              wx.removeStorage({
                key: 'userInfo',
                success: function (res) {
                  app.globalData.userInfo=null;
                }
              })
                wx.redirectTo({
                  url: '../index/index',
                })
            } else {
              wx.showModal({
                title: '错误',
                content: data.desc,
                mode: true,
                showCancel: false,
                confirmColor: '#007aff',
              })
            }
          })
        }
      }
    })

  }
  
})